﻿using Newtonsoft.Json;
using System.Collections.Generic;

namespace AutomationCommand
{
    public class ml_lst_elmt_wit_opt : BasiCommand
    {
        [JsonProperty("table")]
        public Table Table { get; set; }

        [JsonProperty("list")]
        public List<ListItem> List { get; set; }

        [JsonProperty("option")]
        public string Option { get; set; }

        [JsonProperty("sql")]
        public Sql Sql { get; set; }

        [JsonProperty("overtime")]
        public int Overtime { get; set; }

        public ml_lst_elmt_wit_opt()
        {
            FunctionType = "ml_lst_elmt_wit_opt";
            OtherName = "列表元素操作";
            Table = new Table { Type = "", Content = "" };
            List = new List<ListItem> { new ListItem { KeyName = "", Type = "", Content = "" } };
            Option = "";
            Sql = new Sql { TableName = "", Ck = "0", Cdt = new Cdt { K = "", R = "", V = "" } };
            Overtime = 10000;
            SuccessJump = -1;
            FailureJump = -1;
        }

        public bool Execute()
        {
            // 在这里编写执行命令的逻辑
            // 返回执行结果
            return true; // 假设此处始终成功
        }
    }

    public class Table
    {
        [JsonProperty("type")]
        public string Type { get; set; }

        [JsonProperty("content")]
        public string Content { get; set; }
    }

    public class ListItem
    {
        [JsonProperty("keyname")]
        public string KeyName { get; set; }

        [JsonProperty("type")]
        public string Type { get; set; }

        [JsonProperty("content")]
        public string Content { get; set; }
    }

    public class Sql
    {
        [JsonProperty("tablename")]
        public string TableName { get; set; }

        [JsonProperty("ck")]
        public string Ck { get; set; }

        [JsonProperty("cdt")]
        public Cdt Cdt { get; set; }
    }

    public class Cdt
    {
        [JsonProperty("k")]
        public string K { get; set; }

        [JsonProperty("r")]
        public string R { get; set; }

        [JsonProperty("v")]
        public string V { get; set; }
    }
}
